<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>具名插槽的使用</title>
</head>
<body>
<div id="app">
    <cpn></cpn>
    <hr>

    <!--v-slot指令可以用在组件或者<template>标签上，用来定义插槽的内容。-->
    <cpn>
        <template v-slot:center>
            <div>center</div>
        </template>
    </cpn>

    <hr>
    <cpn>
        <template v-slot:left>
            <div>left</div>
        </template>
        <template v-slot:center>
            <div>center</div>
        </template>
        <template v-slot:right>
            <div>right</div>
        </template>
    </cpn>
</div>

<template id="cpn">
    <h1>这是一个自定义组件</h1>
    <slot name="left">
        <span>左边</span>
    </slot>
    <slot name="center">
        <span>中间</span>
    </slot>
    <slot name="right">
        <span>右边</span>
    </slot>
</template>

<script type="module">
    import {createApp, defineComponent} from "../../../js/vue.esm-browser.js";

    let component = defineComponent(
        {
            template: "#cpn",
        }
    );

    let app = createApp(
        {
            setup() {
                return {}
            }
        }
    );

    app.component("cpn", component)
    app.mount("#app")
</script>
</body>
</html>